<template>
  <div>
    <h2>我是About的内容</h2>
  </div>
</template>

<script>
export default {
  // eslint-disable-next-line vue/multi-word-component-names
  name: "About",

  //注意：组件内路由不能称为前置、后置   因为要看调用场景

  //只有通过路由规则，进入该组件时被调用（例如默认引入组件，不调用）
  beforeRouteEnter(to, from, next) {
    console.log("App----beforeRouteEnter");
    console.log(to, from, next);
    if (to.meta.isAuth) {
      if (localStorage.getItem("school") === "atguigu") {
        next();
      } else {
        alert("学校名不对，无权查看");
      }
    } else {
      next();
    }
  },

  beforeRouteLeave(to, from, next) {
    console.log("App----beforeRouteLeave");
    console.log(to, from, next);
    //需要放行，否则切换出去   适用于组件需要个性化处理的场景
    next();
  },
};
</script>

